import React from 'react'
import { HashRouter, Redirect, Route, Switch } from 'react-router-dom'
import Login from '../views/Login/Login'
import Detail from '../views/news/Detail'
import News from '../views/news/News'
import Sanbox from '../views/Sanbox/NewSanbox'
export default function IndexRouter() {
    return (
        <HashRouter>
            <Switch>
                <Route path="/login" component={Login}></Route>
                <Route path="/news" component={News}></Route>
                <Route path="/detail/:id" component={Detail}></Route>

                <Route path="/" render={() =>
                    localStorage.getItem('token') ? <Sanbox></Sanbox> : <Redirect to='/login'></Redirect>
                }></Route>
            </Switch>
        </HashRouter>
    )
}
